package ch.mse.android.starbucksfinder;

import java.io.Serializable;

import android.app.Activity;
import android.location.Location;

public class StarbucksLocation implements Serializable{
	private static final long serialVersionUID = 1L;
	private String name;
	private String address ;
	private String city;
	private String zip;
	private String phone;
	private float latitude;
	private float longitude;
	
	public StarbucksLocation(String name, String address, String city, String zip,
			String phone, float lat, float lng) {
		super();
		this.name = name;
		this.address = address;
		this.city = city;
		this.zip = zip;
		this.phone = phone;
		this.latitude = lat;
		this.longitude = lng;
	}

	public StarbucksLocation() {
		super();
	}
	
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getAddress() {
		return address;
	}
	public void setAddress(String address) {
		this.address = address;
	}
	public String getCity() {
		return city;
	}
	public void setCity(String city) {
		this.city = city;
	}
	public String getZip() {
		return zip;
	}
	public void setZip(String zip) {
		this.zip = zip;
	}
	public String getPhone() {
		return phone;
	}
	public void setPhone(String phone) {
		this.phone = phone;
	}
	public float getLatitude() {
		return latitude;
	}
	public void setLatitude(float latitude) {
		this.latitude = latitude;
	}
	public float getLongitude() {
		return longitude;
	}
	public void setLongitude(float longitude) {
		this.longitude = longitude;
	}
	
	public float distanceTo(Location l){
		Location loc = new Location(Activity.LOCATION_SERVICE);
		loc.setLatitude(getLatitude());
		loc.setLongitude(getLongitude());
		return l.distanceTo(loc);
	}

	@Override
	public boolean equals(Object o){
		if(!(o instanceof StarbucksLocation)){
			return false;
		}
		StarbucksLocation sl = (StarbucksLocation)o;
		return sl.latitude == latitude && sl.longitude == longitude;
	}
	
	@Override
	public String toString() {
		return name + ", " + address + ", "+ zip + " " + city;
	}
	
	public String toMultilineString(){
		return name + "\n" + address + "\n" + zip +" "+ city;
	}
	
}
